#ifndef TTFTESTWIDGET_H
#define TTFTESTWIDGET_H

#include <QWidget>
#include<QOpenGLWidget>
#include<QOpenGLFunctions_4_3_Core>
#include<stb/stb_truetype.h>
#include<BHXJGLHelper/bhxjglshader.h>
#include<BHXJGLHelper/bhxjglcamera.h>
#include<QFile>
#include<QByteArray>
#include<libtess2/tess.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include<QDebug>
#include<array>
#include<QMouseEvent>
#include<QKeyEvent>
#include<BHXJGLHelper/bhxjglttf.h>
#include<BHXJGLHelper/bhxjglmodel.h>


class TTFTestModel:public BHXJGLModel<BHXJGLFUN*,BHXJGLTTF*>
{
public:
    TTFTestModel();

    virtual void Init(BHXJGLFUN *glcore,BHXJGLTTF*)override;


protected:
    BHXJGLTTF *ttf=nullptr;
};







class TTFTestWidget : public QOpenGLWidget,protected QOpenGLFunctions_4_3_Core
{
    Q_OBJECT
public:
    explicit TTFTestWidget(QWidget *parent = nullptr);
    virtual ~TTFTestWidget() override;
    Q_PROPERTY(bool PaintLine READ PaintLine WRITE setPaintLine)
    bool PaintLine(){return _PaintLine;}
    void setPaintLine(bool value){_PaintLine=value;this->update();}
signals:




protected:
    void initializeGL() override;
    void paintGL() override;
    void resizeGL( int width, int height ) override;


    BHXJGLShader shader;
    BHXJGLShader shadernormal;
    BHXJGLCamera camera;
    BHXJGLTTF *ttf;

    TTFTestModel ttfmodl;

    bool _PaintLine=false;

    void fun12(int a,int b);
    glm::mat4 projection;
    int projectionID;
    glm::mat4 model = glm::mat4(1.0f);
    int modelID;
    glm::mat4 view = glm::mat4(1.0f);
    int viewID;

    bool updated=false;
    bool move=true;
    QPoint p;
    QMap<int, bool> keys;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void mouseDoubleClickEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;

    void keyPressEvent(QKeyEvent *e) override;
    void keyReleaseEvent(QKeyEvent *e) override;

    void timerEvent(QTimerEvent *) override;
public slots:
};

#endif // TTFTESTWIDGET_H
